<template>
  <div class="baseA">
    我是A组件(接收方)
    <p>{{ msg }}</p>
    <BaseD></BaseD>
  </div>
</template>

<script>
import BaseD from "./BaseD.vue";
import Bus from "../utils/EventBus";
export default {
  components: { BaseD },
  created() {
    // 2. 监听Bus组件的sendMsg事件，当时事件被触发，执行回调函数
    Bus.$on("sendMsg", msg => {
      // console.log("A组件收到消息：", msg);
      this.msg = msg;
    });
  },
  data() {
    return {
      msg: ""
    };
  }
};
</script>

<style scoped>
.baseA {
  width: 150px;
  height: 80px;
  border: 3px solid #000;
  padding: 10px;
  margin: 10px;
}
</style>